<script language="javascript">
    $(document).ready(function(){
        $("#checkall").click(function(){
            var checked_status = this.checked;
            $('input[type="checkbox"]').each(function(){
               this.checked = checked_status;
            });
        });
    });
</script>

<script language="javascript">
    $(document).ready(function(){
        $("#checkall").click(function(){
            var checked_status = this.checked;
            $('input[type="checkbox"]').each(function(){
               this.checked = checked_status;
            });
        });
    });
</script>
<?php echo $this->Form->create('User',array('action'=>'admin_process')); ?>
<div class="head_title"><h1 align="center">Danh Sách Người Dùng</h1></div>

<?php
//echo  $session->read('Auth.User.username');
//echo "hiennnnnnnnnnnnnnnnnnnnnn : " . $this->Session->read('nhanvien');
?>
<table>
    <thead>
        <tr>
			<th><?php echo $this->Form->checkbox('all',array('id'=>'checkall')); ?></th>
            <th><?php echo $this->Paginator->sort('username', 'TÊN NGƯỜI DÙNG'); ?></th>
            <th><?php echo $this->Paginator->sort('MANV', 'MÃ NHÂN VIÊN'); ?></th>
            <th><?php echo $this->Paginator->sort('CAP', 'CẤP NGƯỜI DÙNG'); ?></th>
            <th>THAY ĐỔI</th>
        </tr>
    </thead>

    <?php foreach ($users as $user): ?>
    <tr>
		<td><?php echo $this->Form->checkbox('User.id.'.$user['User']['id']); ?></td>
        <td><?php echo $user['User']['username']; ?></td>
        <td><?php echo $user['User']['MANV']; ?></td>
        <td><?php echo $user['User']['CAP']; ?></td>
        <!-- $this->Html->link($hanghoa['HangHoa']['TenHG'],
       //    array('controller' => 'hanghoas', 'action' => 'view', $hanghoa['HangHoa']['TenHG'])) -->
        <td><?php  echo $this->Html->link($this->Html->image('/images/user_edit.png'), array('action' => 'edit', $user['User']['id']), array('escape' => false)); ?>
            <?php  echo $this->Html->link($this->Html->image('/images/trash.png'), array('action' => 'delete', $user['User']['id']),
                array('confirm' => 'Bạn có chắc muốn xóa?', 'escape' => false)); ?>

        </td>
    </tr>
    <?php endforeach; ?>
</table>
<?php
     echo $this->Form->end('Xóa các mục đã chọn', array('action' => 'Delete'));
?>
<div id="pagination">
    <div class="paging">
        <?php echo $this->Paginator->first('Trang đầu'); ?>
        <?php echo $this->Paginator->prev('<<' . __('Lùi', true),
        array(), null, array('class' => 'disabled')); ?>
        <?php echo $this->Paginator->numbers(); ?>
        <?php echo $this->Paginator->next(__('Tới', true) . '>>',
        array(), null, array('class' => 'disabled')); ?>
        <?php echo $this->Paginator->last('Trang cuối'); ?>
    </div>
</div>
<br/><br/>
<?php
echo $this->Html->link('Thêm người dùng', array('controller' => 'users', 'action' => 'add'), array('class' => 'add'));
?>
